function getLocalTime(nS) {     
   return new Date(parseInt(nS)).toLocaleString().replace(/:\d{1,2}$/,' ');     
}
function getQueryString(name) { 
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	var r = window.location.search.substr(1).match(reg); 
	if (r != null) return unescape(r[2]); 
	return null; 
} 
var orderNo;
/**
 设备设备应答远程重启
 * @param {Object} baseSn
 * @param {Object} deviceCode
 * @param {Object} slotPosition
 */
function send0110(type,cmd){
	var baseSn = $("#baseSn").val();
	var param = $("#0110Param").val();
	console.log("send0110:::baseSn:",baseSn,",type:",type,",cmd:",cmd,",param:",param)
	reqGet.ajax("/app/cmd/"+type+"/"+cmd+"?sn="+baseSn+"&param="+encodeURI(param),function(result){
		orderNo = result.data;
		$("#send0110Res").val(orderNo);
		success(result,result.msg);
	})
}
/**
 服务器下发收费方案
 * @param {Object} baseSn
 * @param {Object} deviceCode
 * @param {Object} slotPosition
 */
function send0102(type,cmd){
	var baseSn = $("#baseSn").val();
	var param = $("#0102Param").val();
	console.log("send0102:::baseSn:",baseSn,",type:",type,",cmd:",cmd,",param:",param)
	reqGet.ajax("/app/cmd/"+type+"/"+cmd+"?sn="+baseSn+"&param="+encodeURI(param),function(result){
		orderNo = result.data;
		$("#send0102Res").val(orderNo);
		success(result,result.msg);
	})
}
/**
 服务器启动充电
 * @param {Object} baseSn
 * @param {Object} deviceCode
 * @param {Object} slotPosition
 */
function send0105(type,cmd){
	var baseSn = $("#baseSn").val();
	var param = $("#0105Param").val();
	console.log("send0105:::baseSn:",baseSn,",type:",type,",cmd:",cmd,",param:",param)
	reqGet.ajax("/app/cmd/"+type+"/"+cmd+"?sn="+baseSn+"&param="+encodeURI(param),function(result){
		orderNo = result.data;
		$("#send0105Res").val(orderNo);
		success(result,result.msg);
	})
}
/**
 服务器停止充电
 * @param {Object} baseSn
 * @param {Object} deviceCode
 * @param {Object} slotPosition
 */
function send0106(type,cmd){
	var baseSn = $("#baseSn").val();
	var param = $("#0106Param").val();
	console.log("send0106:::baseSn:",baseSn,",type:",type,",cmd:",cmd,",param:",param)
	reqGet.ajax("/app/cmd/"+type+"/"+cmd+"?sn="+baseSn+"&param="+encodeURI(param),function(result){
		orderNo = result.data;
		$("#send0106Res").val(orderNo);
		success(result,result.msg);
	})
}
/**
 服务器设置设备工作参数
 * @param {Object} baseSn
 * @param {Object} deviceCode
 * @param {Object} slotPosition
 */
function send010B(type,cmd){
	var baseSn = $("#baseSn").val();
	var param = $("#010BParam").val();
	console.log("send010B:::baseSn:",baseSn,",type:",type,",cmd:",cmd,",param:",param)
	reqGet.ajax("/app/cmd/"+type+"/"+cmd+"?sn="+baseSn+"&param="+encodeURI(param),function(result){
		orderNo = result.data;
		$("#send010BRes").val(orderNo);
		success(result,result.msg);
	})
}
/**
 * 语音播报测试
 */
function voice(){
	var baseSn = $("#baseSn").val();
	var voiceContent = $("#voiceContent").val();
	reqGet.ajax("/app/client/deb/voice?baseSn="+baseSn+"&param="+voiceContent,function(result){
		success(result,result.msg);
	})
}
/**
 * 停止出液
 * @param {Object} baseSn
 * @param {Object} slotPosition
 */
function stopWash(){
	var baseSn = $("#baseSn").val();
	var outPort = $("input[name='outPort']:checked").val();
	var param = outPort;
	console.log("stopWash:::baseSn:",baseSn,",outPort:",outPort)
	reqGet.ajax("/app/client/deb/09?baseSn="+baseSn+"&param="+param,function(result){
		success(result,result.msg);
	})
}
/**
 * 设置出液重量换算
 */
function setOutWeight(){
	var outWeight = $("#outWeight").val();
	reqGet.ajax("/app/client/deb/calc/"+outWeight+"?type=1",function(result){
		console.log("setOutWeight==>result:",result)
		$("#pulseNum").val(result.data.pulseNum);
		$("#pulseNumHex").val(result.data.pulseNumHex);
	})
}
/**
 * 设置出液重量换算
 */
function setPulseNumHext(){
	var pulseNum = $("#pulseNum").val();
	reqGet.ajax("/app/client/deb/calc/"+pulseNum+"?type=2",function(result){
		console.log("setPulseNumHext==>result:",result)
		$("#pulseNumHex").val(result.data.pulseNumHex);
	})
}
/**
 * 查询订单状态
 * @param {Object} orderNo
 */
function querySendStatus(orderNo){
	if(null == orderNo){
		console.log('订单号为空,不执行查询')
		return;
	}
	reqGet.ajax("/app/client/deb/queryOrder/"+orderNo,function(result){
		success(result,result.data);
		var data = result.data;
		var type = data.type;
		if(type == "01"){
			$("#orderNo").text(data.orderNo);
			$("#sendTime").text(data.sendTime);
		}else{
			$("#resOrderNo").text(data.orderNo);
			$("#cargoWayNo").text(data.cargoWayNo);
			$("#pulseNum").text(data.pulseNum);
			$("#decimalPulseNum").text(data.decimalPulseNum);
			$("#weight").text(data.weight);
			$("#commandCount").text(data.commandCount);
			$("#resTime").text(data.resTime);
		}
	})
}
/**
 * 监听指令响应状态
 */
function orderResStatus(){
	querySendStatus(orderNo);
}